# python3

import sys

def printUsage():
    print('new_fmt.py <file>')

if len(sys.argv) != 2:
    printUsage()
    exit(1)

with open(sys.argv[1], encoding='UTF-8') as f:
    while True:
        line = f.readline()
        if line == '':
            break
        items = line.split('$')
        if line[0] == '#' or len(items) != 6:
            print(line, end='')
            continue
        print('%s$%s$%s$%s$%s$WORD$'%(\
            items[0], \
            items[1], \
            items[2], \
            items[3], \
            items[4] + '[%s]'%(items[5].strip())))
        